#pragma once
#include "ICamera.h"
#include "ICoreGraphic.h"
#include "ArkD3DBase.h"

#define	MAX_FILTER	5

//namespace ArkGraphic
// {

class CCamera :	public ICamera,IRenderSystem
{
	D3DXVECTOR3				m_CurCameraUp;
	D3DXVECTOR3				m_CurCameraDir;
	D3DXVECTOR3				m_CurCameraPos;
	D3DXVECTOR3				m_CurCameraDest;
	D3DXMATRIX				m_matView; 
	D3DXMATRIX				m_matViewInvert; 
	D3DXMATRIX				m_matBillboardNoneX;
	D3DXMATRIX				m_matBillboardAll; 

	float					m_FovY;
	float					m_zNear;
	float					m_zFar;
	D3DXMATRIX				m_matProj; 

	D3DXMATRIX				m_matViewProject;

	IGraphic*				m_pIGraphic;

	D3DXMATRIX				m_matPreDeltaView; 
	D3DXMATRIX				m_matPreDeltaProj; 
	D3DXMATRIX				m_matCurDeltaView; 
	D3DXMATRIX				m_matCurDeltaProj; 
	D3DVIEWPORT9			m_VPort;

	struct Filter
	{
		ITexture*			pText;
		DWORD				dwColor;
		BOOL				bMulti;
	};

	int						m_nNearCount;
	Filter					m_NearFilter[MAX_FILTER];
	int						m_nFarCount;
	Filter					m_FarFilter[MAX_FILTER];

public:
	CCamera(void);
	virtual ~CCamera(void);

	void								Create( ICoreGraphic* pGraphic );
	void								Release();
	void								Flip();
	const D3DXMATRIX&					GetViewProject(){ return m_matViewProject; }
	const D3DVIEWPORT9&					GetViewPort()	{ return m_VPort;	}

	virtual void						AddFilter( ITexture* pTexture, DWORD Color, BOOL bNear, BOOL bMulti );
	virtual void						AddCameraOff( float xDelta, float yDelta, float zDelta );
	virtual void						SetCameraUp( const CVector3f& CameraUp );
	virtual void						SetCamera( const CVector3f& CameraPos, const CVector3f& CameraDest );
	virtual void						SetCameraPosition(const CVector3f& CameraPos);
	virtual void						SetCameraLookAt(const CVector3f& CameraLookAt);
	virtual void						GetCamera( CVector3f& CameraPos, CVector3f& CameraDest );
	virtual void						GetCamera( CMatrix& View );
	virtual void						GetCameraUp( CVector3f& CameraUp );
	virtual void						GetCameraDir( CVector3f& CameraDir );
	virtual void						GetBillboardNoneX( CMatrix& Billboard );
	virtual void						GetBillboardAll( CMatrix& Billboard );
	virtual void						GetCameraInvert( CMatrix& ViewInvert );
	virtual void						SetProject( float fovY, float zNear, float zFar );
	virtual void						SetProject( const CMatrix& Proj );
	virtual void						GetProject( float& fovY, float& zNear, float& zFar );
	virtual void						GetProject( CMatrix& Proj );
	virtual void						GetViewport( CIRect& Viewport );

	virtual void						PreRender( ICamera* /*pCamera*/, ARKLIGHT& /*ArkLight*/, uint32& /*nAmbient*/ ){};
	virtual void						Render();
};

// }
